# -*- coding: utf-8 -*-
# Date: 2025-01-02
# Author: HonestQiao
#
# Desc: nano-gui 行空板K10屏幕配置

from machine import Pin, SPI, SoftSPI
import gc

from drivers.ili93xx.ili9341 import ILI9341 as SSD

TFT_MOSI = 21
TFT_SCLK  = 12
TFT_CS  = 14
TFT_DC  = 13
TFT_RST = 46 # 占位

pdc = Pin(TFT_DC, Pin.OUT, value=0)  # Arbitrary pins
pcs = Pin(TFT_CS, Pin.OUT, value=1)
prst = Pin(TFT_RST, Pin.OUT, value=1)

gc.collect()

try:
    spi = SPI(1, 30_000_000, sck=Pin(TFT_SCLK), mosi=Pin(TFT_MOSI))
    print("屏幕驱动使用硬件SPI，速度快")
except Exception as e:
    spi = SoftSPI(30_000_000, sck=Pin(TFT_SCLK), mosi=Pin(TFT_MOSI), miso=Pin(0))
    print("屏幕驱动使用软SPI，速度可能不快")
ssd = SSD(spi, height=320, width=240, dc=pdc, cs=pcs, rst=prst, usd=False)
